var home = {
	// 属性
	// 方法
	search: function(e) {
		var a = false;
		$('.search-icon').click(function() {
			a = false;
			stopEvent(event);
			$('#search-input').focus();
			$('#search-submit').css({
				"display": "block"
			});
			$('.header-search').addClass("active-search");
			$('.search-icon').css({"color":"#666262"});
		});
		$('#search-input').blur(function() {
			$('body').click(function() {
				a = true;
				if(a) {
					a = false;
					$('#search-submit').css({
						"display": "none"
					});
					$('.header-search').removeClass("active-search");
					$('.search-icon').css({"color":"#fff"});
				}
			});
			$('#search-submit').click(function() {
				a = false;
				stopEvent(event);
			});
			$('#search-input').click(function() {
				a = false;
				stopEvent(event);
			});
		});

		function stopEvent(event) { //阻止冒泡事件
			//取消事件冒泡
			//若省略此句，下面的e改为event，IE运行可以，但是其他浏览器就不兼容
			//grunt 会报错。。
			//var e = arguments.callee.caller.arguments[0] || event;
			
			if(event && event.stopPropagation) {
				// this code is for Mozilla and Opera
				event.stopPropagation();
			} else if(window.event) {
				// this code is for IE
				window.event.cancelBubble = true;
			}
		}
	}, 
	init: function() {
		var Img = $('#imgRund .img-boxs img');
		var buttons = $('#imgRund .content .home-prev');
		var points = $('#points li');
		var Imgsize = Img.size();
		var index = 0;
		var autoStart = setInterval(autoshow, 3000);
		function change(index) {
			points.removeClass('prevous-active');
			points.eq(index).addClass('prevous-active');
			Img.eq(index).siblings().animate({
				opacity: 0
			}, 1000);
			Img.eq(index).animate({
				opacity: 1
			}, 1000);
		}

		function autoshow() {
			index++;
			if(index <= Imgsize - 1) {
				change(index);
			} else {
				index = 0;
				change(index);
			}
		}
		points.click(function(){
			clearInterval(autoStart);
			$(this).addClass('prevous-active');
			index = $(this).index();
			change(index);
		});
		$('#next').click(function() {
			clearInterval(autoStart);
			index++;
			if(index > Imgsize - 1) {
				index = 0;
				change(index);
			}
			change(index);
		});
		$('#prev').click(function() {
			clearInterval(autoStart);
			index--;
			if(index < 0) {
				index = Imgsize - 1;
			}
			change(index);
		});
		

		function clearInt() {
			$(".content").mouseover(function() {
				clearInterval(autoStart);
			});
		}

		function setInt() {
			$(".content").mouseout(function() {
				autoStart = setInterval(autoshow, 3000);
			});
		}
		clearInt();
		setInt();
	}
};